<?php

namespace app\api\controller;

use app\common\controller\Api;

class Card extends Api
{
    protected $noNeedRight = ['*'];

    //会员卡信息
    public function cardinfo()
    {
        $card = \app\admin\model\Card::get(1);

        $this->success('',$card);
    }

    //计算打折价格
    public function calculate()
    {

        $card_model = new \app\admin\model\CardOrder();
        $discount = input('discount',0);

        $res = $card_model->calculate($discount);
        $this->success('成功',$res);
    }

    //创建会员卡
    public function create()
    {
        try {
            $card_model = new \app\admin\model\CardOrder();
            $param = input();
            $param['user_id'] = $this->auth->id;
            $res = $card_model->add($param);

        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('发布成功',$res);
    }
}